#include <rtthread.h>
#include <board.h>
#include "spi_flash_sfud.h"
#include "drv_spi.h"

#define FLASH_DRV_SPI_BUS           "spi2"
#define FLASH_DRV_SPI_DEV           "spi2w25"
#define FLASH_DEV_NAME              "w25q128"

int flash_driver_init(void)
{
    rt_hw_spi_device_attach(FLASH_DRV_SPI_BUS, FLASH_DRV_SPI_DEV, GPIOB, GPIO_PIN_12);

    if(rt_sfud_flash_probe(FLASH_DEV_NAME, FLASH_DRV_SPI_DEV))
    {
        rt_kprintf("Flash driver init success\r\n");
    }
    else
    {
        rt_kprintf("Flash driver init failed\r\n");
        return RT_ERROR;
    }
    return RT_EOK;
}
INIT_DEVICE_EXPORT(flash_driver_init);
